package com.lmall.book.controller;

import com.lmall.api.dto.BookDTO;
import com.lmall.book.service.IBookService;
import com.lmall.common.utils.BeanUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Api(tags = "图书管理相关接口")
@RestController
@RequestMapping("/books")
@RequiredArgsConstructor
public class BookController {

    private final IBookService bookService;

    @ApiOperation("根据id查询图书")
    @GetMapping("/{id}")
    public BookDTO getBookById(@PathVariable Integer id) {
        return BeanUtils.copyBean(bookService.getById(id), BookDTO.class);
    }

}
